/*
 *    Copyright (c) 2018-2025, lengleng All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the pig4cloud.com developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: lengleng (wangiegie@gmail.com)
 */

package com.pig4cloud.pigx.basics.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pig4cloud.pigx.basics.entity.Xzg3Goods;
import com.pig4cloud.pigx.basics.service.Xzg3GoodsService;
import com.pig4cloud.pigx.common.core.util.R;
import com.pig4cloud.pigx.common.log.annotation.SysLog;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;


/**
 * ${comments}
 *
 * @author pigx code generator
 * @date 2021-10-26 13:37:17
 */
@RestController
@AllArgsConstructor
@RequestMapping("/xzg3goods" )
@Api(value = "xzg3goods", tags = "${comments}管理")
public class Xzg3GoodsController {

    private final Xzg3GoodsService xzg3GoodsService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param xzg3Goods ${comments}
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page" )
    @PreAuthorize("@pms.hasPermission('goods_xzg3goods_view')" )
    public R getXzg3GoodsPage(Page page, Xzg3Goods xzg3Goods) {
        return R.ok(xzg3GoodsService.page(page, Wrappers.query(xzg3Goods)));
    }


    /**
     * 通过id查询${comments}
     * @param fId id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{fId}" )
    @PreAuthorize("@pms.hasPermission('goods_xzg3goods_view')" )
    public R getById(@PathVariable("fId" ) String fId) {
        return R.ok(xzg3GoodsService.getById(fId));
    }

    /**
     * 新增${comments}
     * @param xzg3Goods ${comments}
     * @return R
     */
    @ApiOperation(value = "新增${comments}", notes = "新增${comments}")
    @SysLog("新增${comments}" )
    @PostMapping
    @PreAuthorize("@pms.hasPermission('goods_xzg3goods_add')" )
    public R save(@RequestBody Xzg3Goods xzg3Goods) {
        return R.ok(xzg3GoodsService.save(xzg3Goods));
    }

    /**
     * 修改${comments}
     * @param xzg3Goods ${comments}
     * @return R
     */
    @ApiOperation(value = "修改${comments}", notes = "修改${comments}")
    @SysLog("修改${comments}" )
    @PutMapping
    @PreAuthorize("@pms.hasPermission('goods_xzg3goods_edit')" )
    public R updateById(@RequestBody Xzg3Goods xzg3Goods) {
        return R.ok(xzg3GoodsService.updateById(xzg3Goods));
    }

    /**
     * 通过id删除${comments}
     * @param fId id
     * @return R
     */
    @ApiOperation(value = "通过id删除${comments}", notes = "通过id删除${comments}")
    @SysLog("通过id删除${comments}" )
    @DeleteMapping("/{fId}" )
    @PreAuthorize("@pms.hasPermission('goods_xzg3goods_del')" )
    public R removeById(@PathVariable String fId) {
        return R.ok(xzg3GoodsService.removeById(fId));
    }

}
